package suites.as3Core.utilites.bitwise.cases
{
	import com.powwow.as3Core.utilites.bitwise.setBitsOn;

	import org.flexunit.asserts.assertEquals;

	public class BitwiseSetBitsOnTest
	{

		[Before]
		public function setUp():void
		{
		}

		[After]
		public function tearDown():void
		{
		}

		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}

		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}


		[Test]
		public function test_zero_zero():void
		{
			//given 
			const value:uint=0;
			const bits:uint=0;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(0, result);
		}

		[Test]
		public function test_zero_nonzero():void
		{
			//given 
			const value:uint=0;
			const bits:uint=6;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(6, result);
		}

		[Test]
		public function test_nonzero_zero():void
		{
			//given 
			const value:uint=6;
			const bits:uint=0;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(6, result);
		}

		[Test]
		public function test_with_maxInt1():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=0xFFFFFFFF;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(0xFFFFFFFF, result);
		}

		[Test]
		public function test_with_maxInt2():void
		{
			//given 
			const value:uint=0xFFFFFFFF;
			const bits:uint=0xF00FF00F;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(0xFFFFFFFF, result);
		}

		[Test]
		public function test_with_maxInt3():void
		{
			//given 
			const value:uint=0;
			const bits:uint=0xFFFFFFFF;
			//when 
			const result:uint=setBitsOn(value, bits);
			//then
			assertEquals(0xFFFFFFFF, result);
		}

		[Test]
		public function test_turn_on_matched():void
		{
			//given 
			const value:uint=parseInt("100000110", 2);
			const _bits:uint=parseInt("100000110", 2);
			const _res_:uint=parseInt("100000110", 2);
			//when 
			const result:uint=setBitsOn(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_on_intersected():void
		{
			//given 
			const value:uint=parseInt("100110110", 2);
			const _bits:uint=parseInt("100010010", 2);
			const _res_:uint=parseInt("100110110", 2);
			//when 
			const result:uint=setBitsOn(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_on_nonintersected():void
		{
			//given 
			const value:uint=parseInt("000110110", 2);
			const _bits:uint=parseInt("100000000", 2);
			const _res_:uint=parseInt("100110110", 2);
			//when 
			const result:uint=setBitsOn(value, _bits);
			//then
			assertEquals(_res_, result);
		}

		[Test]
		public function test_turn_on_nonintersected2():void
		{
			//given 
			const value:uint=parseInt("000110110", 2);
			const _bits:uint=parseInt("100011011", 2);
			const _res_:uint=parseInt("100111111", 2);
			//when 
			const result:uint=setBitsOn(value, _bits);
			//then
			assertEquals(_res_, result);
		}
	}
}
